/******************************************************************************* 
 *  Copyright 2007 Amazon Technologies, Inc.  
 *  Licensed under the Apache License, Version 2.0 (the "License"); 
 *  
 *  You may not use this file except in compliance with the License. 
 *  You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
 *  This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
 *  CONDITIONS OF ANY KIND, either express or implied. See the License for the 
 *  specific language governing permissions and limitations under the License.
 * ***************************************************************************** 
 *    __  _    _  ___ 
 *   (  )( \/\/ )/ __)
 *   /__\ \    / \__ \
 *  (_)(_) \/\/  (___/
 * 
 *  Amazon ECS CSharp Library
 *  API Version: 2007-07-16
 *  Generated: Thu Aug 02 10:15:38 PDT 2007 
 * 
 */

using System;
using System.Xml.Serialization;
using System.Collections.Generic;
using System.Text;


namespace Amazon.ECS.Model
{
    [XmlTypeAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16")]
    [XmlRootAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16", IsNullable = false)]
    public class Feedback
    {
    
        private Decimal? ratingField;

        private String commentField;

        private String dateField;

        private String ratedByField;


        /// <summary>
        /// Gets and sets the Rating property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Rating")]
        public Decimal Rating
        {
            get { return this.ratingField.GetValueOrDefault() ; }
            set { this.ratingField= value; }
        }



        /// <summary>
        /// Sets the Rating property
        /// </summary>
        /// <param name="rating">Rating property</param>
        /// <returns>this instance</returns>
        public Feedback WithRating(Decimal rating)
        {
            this.ratingField = rating;
            return this;
        }



        /// <summary>
        /// Checks if Rating property is set
        /// </summary>
        /// <returns>true if Rating property is set</returns>
        public Boolean IsSetRating()
        {
            return  this.ratingField != null;

        }


        /// <summary>
        /// Gets and sets the Comment property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Comment")]
        public String Comment
        {
            get { return this.commentField ; }
            set { this.commentField= value; }
        }



        /// <summary>
        /// Sets the Comment property
        /// </summary>
        /// <param name="comment">Comment property</param>
        /// <returns>this instance</returns>
        public Feedback WithComment(String comment)
        {
            this.commentField = comment;
            return this;
        }



        /// <summary>
        /// Checks if Comment property is set
        /// </summary>
        /// <returns>true if Comment property is set</returns>
        public Boolean IsSetComment()
        {
            return  this.commentField != null;

        }


        /// <summary>
        /// Gets and sets the Date property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Date")]
        public String Date
        {
            get { return this.dateField ; }
            set { this.dateField= value; }
        }



        /// <summary>
        /// Sets the Date property
        /// </summary>
        /// <param name="date">Date property</param>
        /// <returns>this instance</returns>
        public Feedback WithDate(String date)
        {
            this.dateField = date;
            return this;
        }



        /// <summary>
        /// Checks if Date property is set
        /// </summary>
        /// <returns>true if Date property is set</returns>
        public Boolean IsSetDate()
        {
            return  this.dateField != null;

        }


        /// <summary>
        /// Gets and sets the RatedBy property.
        /// </summary>
        [XmlElementAttribute(ElementName = "RatedBy")]
        public String RatedBy
        {
            get { return this.ratedByField ; }
            set { this.ratedByField= value; }
        }



        /// <summary>
        /// Sets the RatedBy property
        /// </summary>
        /// <param name="ratedBy">RatedBy property</param>
        /// <returns>this instance</returns>
        public Feedback WithRatedBy(String ratedBy)
        {
            this.ratedByField = ratedBy;
            return this;
        }



        /// <summary>
        /// Checks if RatedBy property is set
        /// </summary>
        /// <returns>true if RatedBy property is set</returns>
        public Boolean IsSetRatedBy()
        {
            return  this.ratedByField != null;

        }




        /// <summary>
        /// XML fragment representation of this object
        /// </summary>
        /// <returns>XML fragment for this object.</returns>
        /// <remarks>
        /// Name for outer tag expected to be set by calling method. 
        /// This fragment returns inner properties representation only
        /// </remarks>


        protected internal String ToXMLFragment() {
            StringBuilder xml = new StringBuilder();
            if (IsSetRating()) {
                xml.Append("<Rating>");
                xml.Append(this.Rating);
                xml.Append("</Rating>");
            }
            if (IsSetComment()) {
                xml.Append("<Comment>");
                xml.Append(EscapeXML(this.Comment));
                xml.Append("</Comment>");
            }
            if (IsSetDate()) {
                xml.Append("<Date>");
                xml.Append(EscapeXML(this.Date));
                xml.Append("</Date>");
            }
            if (IsSetRatedBy()) {
                xml.Append("<RatedBy>");
                xml.Append(EscapeXML(this.RatedBy));
                xml.Append("</RatedBy>");
            }
            return xml.ToString();
        }

        /**
         * 
         * Escape XML special characters
         */
        private String EscapeXML(String str) {
            StringBuilder sb = new StringBuilder();
            foreach (Char c in str)
            {
                switch (c) {
                case '&':
                    sb.Append("&amp;");
                    break;
                case '<':
                    sb.Append("&lt;");
                    break;
                case '>':
                    sb.Append("&gt;");
                    break;
                case '\'':
                    sb.Append("&#039;");
                    break;
                case '"':
                    sb.Append("&quot;");
                    break;
                default:
                    sb.Append(c);
                    break;
                }
            }
            return sb.ToString();
        }




    }

}